package com.wjm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.wjm.entity.Building;
import com.wjm.mapper.interf.BuildingMapper;
import com.wjm.service.interf.BuildingServiceInterface;

@Service("buildingService")
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) // 注明需要回滚
public class BuildingServiceImpl implements BuildingServiceInterface {

	@Autowired
	private BuildingMapper buildingMapper;

	@Override
	public boolean save(Building object) throws Exception {
		boolean result = false;
		if (buildingMapper.save(object) > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean delete(int objectId) throws Exception {
		boolean result = false;
		if (buildingMapper.delete(objectId) > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean update(Building object) throws Exception {
		boolean result = false;
		if (buildingMapper.update(object) > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public int saveBatch(List<Building> list) throws Exception {
		return buildingMapper.saveBatch(list);
	}

	@Override
	public List<Building> queryAll() throws Exception {
		return buildingMapper.selectAll();
	}

	@Override
	public List<Building> queryByPage(int page, int number, int status) throws Exception {
		page = (page - 1) * number;
		return buildingMapper.selectByPage(page, number, status);
	}

	@Override
	public int queryTotal(int status) throws Exception {
		return buildingMapper.selectTotal(status);
	}

}
